package com.example.demo.context;

/**
 *@Description 用户会话上下文
 *@Author Levi
 *@Date 2019/4/23-13:20
*/
public class Context {
    private static ThreadLocal<Context> context = new ThreadLocal<Context>(){
        @Override
        protected Context initialValue() {
            return new Context();
        }
    };
    private CurrentOperator currentOperator;

    public CurrentOperator getCurrentOperator(){
        return currentOperator;
    }
    public void setCurrentOperator(CurrentOperator currentOperator){
        this.currentOperator = currentOperator;
    }
    /**
     * 返回当前的上下文
     * */
    public static Context currentContext(){
        return context.get();
    }
    public static void remove(){
        context.remove();
    }
}
